Procedure to create a custom Cue based on a query and a normal field in Dynamics NAV

Introduction: To show visual representation of aggregated data in Microsoft Dynamics NAV client, tiles are created in NAV which are called Cues. Cues are more user-friendly. It helps the user to get quick details of aggregated data like the total number of open sales orders, total number of customers with a particular status, etc.

Pre-Requisite:

Microsoft Dynamics NAV

Purpose: In this article, I am going to demonstrate the procedure to create a custom Cue based on a query in Dynamics NAV. The scenario which I am going to elaborate is the numbers of contracts which is a custom entity repossessed in the current month.

Procedure:

  1. I have created a field ‘Status’ in my custom table ‘Contracts’ which is an option field which has the following OptionString ‘Created,Active,Terminated,Ended,Repossessed,Switched’. Now I am creating a cue to find the total number of contracts repossessed in the current month that means the total number of contracts for which status has been changed to ‘Repossessed’ in the current month.
  2. I have created two fields in ‘Contracts’ table viz. ‘Repossessed month’ and ‘Repossessed Year’ which will get populated with the Month name and the Year when the Contract status has been changed to ‘Repossessed’ respectively.

image001

  1. The next step is to create a query. I have created a query ‘CF_RepossessedMonthQuery’ which will give the count of the total number of contracts repossessed in the current month.

image002

The result of the query is as follows:

image004

  1. Now create a field in a new table which will store the count of the number of repossessed contracts in the current month. For this, I have created a new field in a table ‘RepossessedContractsMonth’ of DataType ‘Integer’. 
  1. Navigate to C/AL globals and create two new functions as below. a.‘ContractsRepossessedThisMonth’ with Return Value Name ‘CountContracts’ and ReturnType ‘Integer’ and the following local variables.

image005

Navigate to properties and set the local property of this function to ‘No’. Go to C/AL code and add the following code for this function:

image008

b. ‘DrillDownContractsRepossessedThisMonth’ with the following local variables:

 image009

Navigate to properties and set the local property of this function to ‘No’. Go to C/AL code and add the following code for this function:

image011

‘DrillDownContractsRepossessedThisMonth’ is created so that on clicking the cue the respective records open in a list.

  1. The next page is to add the field created in step 4. Create a new group in a page with subtype ‘CueGroup’ 

image012

  1. Go to C/AL code and in OnOpenPage() add the following code:

image014

  1. In OnAfterGetRecord() add the following code:

Assign the function created in step 5.a to the field added in the page ‘RepossessedContractsMonth’.

image015

In OnDrillDown() of RepossessedContractsMonth add the following code which will call the function created in step 5.b.

image016

  1. Save the changes and run the page created in step 6. The output looks like below:      image017

On clicking the ‘Contracts Repossessed this Month’ Cue the 2 respective contracts are displayed whose status has been changed to ‘Repossessed’ in the current month.

image018

You can add these cues to any standard role center page like Business Manager Role Center, Sales Manager Role Center, etc.  so that the cues are visible when the user opens the NAV client.

Conclusion:

Using the above procedure, custom cues can be created in Dynamics NAV which will be displayed.

Thanks for reading my blog!

Leave a comment